home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / lang / Python16_Src.lha / Python16_Source / Tools / compiler / compile.py next >
Encoding:
Python Source  |  2000-05-03  |  722 b   |  29 lines

  1. import sys
  2. import getopt
  3.  
  4. from compiler import compile, visitor
  5.  
  6. def main():
  7.     VERBOSE = 0
  8.     opts, args = getopt.getopt(sys.argv[1:], 'vq')
  9.     for k, v in opts:
  10.         if k == '-v':
  11.             VERBOSE = 1
  12.             visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1
  13.         if k == '-q':
  14.             if sys.platform[:3]=="win":
  15.                 f = open('nul', 'wb') # /dev/null fails on Windows...
  16.             else:
  17.                 f = open('/dev/null', 'wb')
  18.             sys.stdout = f
  19.     if not args:
  20.         print "no files to compile"
  21.     else:
  22.         for filename in args:
  23.             if VERBOSE:
  24.                 print filename
  25.             compile(filename)
  26.  
  27. if __name__ == "__main__":
  28.     main()
  29.